from dao.base_dao import BaseDao
from orm_domain.runner import Runner
from server import db_session


class RunnerDao(BaseDao):
    def get_by_id(self,id):
        return self.query(Runner).filter_by(id = id).first()

    def get_list(self) -> list:
        return self.query(Runner).all()

    def get_list_by_name(self,name):
        name = "%"+name+"%"
        return self.query(Runner).filter(Runner.name.like(name)).all()


    def save(self,runner:Runner) -> int:
        return self.add(runner)


